package com.winit.ogg.util;

import com.winit.common.util.Constants;
import com.winit.common.util.ShellRunUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * 修改tom配置文件
 * Created by wangjian on 2017/9/25.
 */
public class TomUtil {

    private static Logger logger = LoggerFactory.getLogger(TomUtil.class);

    public static void updateTomConfig(boolean flag) {
        String text = "'IS_PRODUCTION_ENV'=>" + flag + ",";
        String cmd = "source /etc/profile && cd " + Constants.TOM_CONFIG_DIR
                + " && sed -i \"s/.*IS_PRODUCTION_ENV.*/" + text + "/\" " + Constants.TOM_CONFIG_FILE;
        Map<String, Object> map = ShellRunUtil.runCmds(cmd);
        logger.info("com.winit.ogg.util.TomUtil.updateTomConfig cmd:" + cmd + ".map:" + map);
    }
}
